#pragma once
#ifndef __G_SEMAPHORE_H__
#define __G_SEMAPHORE_H__

#include <string>

#include "GSynchronizer.h"
#include "GTypes.h"

namespace GThread
{

	class GSemaphore : public GWaitable
	{
	protected:
		void*			Semaphore;
		
		GUInt32			MaximumCount;
		std::string		Name;

	public:
						GSemaphore();
						~GSemaphore();
		
		void*			GetHandle() const;

		const char*		GetName() const;
		GUInt32			GetMaximumCount() const;

		bool			IsCreated() const;

		bool			Create(GUInt32 InitialCount, GUInt32 MaximumCount, const char* Name)  PLATFORM;
		void			Release()  PLATFORM;

		GWaitResult		Acquire(GUInt32 TimeOut = G_TIMEOUT_INFINITE);
		bool			Free(GUInt32 Count = 1) PLATFORM;

	};
}

#endif